exports.install = function (Vue, options) {
    /** 
     * 时间转换为相应格式
    */
    Vue.prototype.formatDate = (date, fmt) => {
        if (/(y+)/.test(fmt)) {
            fmt = fmt.replace(RegExp.$1, (date.getFullYear() + '').substr(4 - RegExp.$1.length));
        }
        let o = {
            'M+': date.getMonth() + 1,
            'd+': date.getDate(),
            'h+': date.getHours(),
            'm+': date.getMinutes(),
            's+': date.getSeconds()
        };
        for (let k in o) {
            if (new RegExp(`(${k})`).test(fmt)) {
                let str = o[k] + '';
                fmt = fmt.replace(RegExp.$1, (RegExp.$1.length === 1) ? str : ('00' + str).substr(str.length));
            }
        }
        return fmt;
    };
    //获取当前时间
    Vue.prototype.getimeto = function (format) {
        var date = new Date();
        var seperator1 = "-";
        var seperator2 = ":";
        //以下代码依次是获取当前时间的年月日时分秒
        var year = date.getFullYear();
        var month = date.getMonth() + 1;
        var strDate = date.getDate();
        var minute = date.getMinutes();
        var hour = date.getHours();
        var second = date.getSeconds();
        //固定时间格式
        if (month >= 1 && month <= 9) {
            month = "0" + month;
        }
        if (strDate >= 0 && strDate <= 9) {
            strDate = "0" + strDate;
        }
        if (hour >= 0 && hour <= 9) {
            hour = "0" + hour;
        }
        if (minute >= 0 && minute <= 9) {
            minute = "0" + minute;
        }
        if (second >= 0 && second <= 9) {
            second = "0" + second;
        }
        if (format) {
            var currentdate = year + seperator1 + month + seperator1 + strDate + " " + hour + seperator2 + minute + seperator2 + second;
            return currentdate;
        } else {
            var currentdate = "" +year + month + strDate + hour + minute +  second
            return currentdate;
        }
    }
    //当前月默认值
    Vue.prototype.getimemon = function () {
        var date = new Date();
        var seperator1 = "-";
        var seperator2 = ":";
        //以下代码依次是获取当前时间的年月日时分秒
        var year = date.getFullYear();
        var month = date.getMonth() + 1;
        var strDate = date.getDate();
        var minute = date.getMinutes();
        var hour = date.getHours();
        var second = date.getSeconds();
        //固定时间格式
        if (month >= 1 && month <= 9) {
            month = "0" + month;
        }
        if (strDate >= 0 && strDate <= 9) {
            strDate = "0" + strDate;
        }
        if (hour >= 0 && hour <= 9) {
            hour = "0" + hour;
        }
        if (minute >= 0 && minute <= 9) {
            minute = "0" + minute;
        }
        if (second >= 0 && second <= 9) {
            second = "0" + second;
        }
        var currentdate = year + seperator1 + month + seperator1 + strDate
            + " " + hour + seperator2 + minute + seperator2 + second;
        return currentdate;
    }
    //上月默认值
    Vue.prototype.lasttimemon = function (format) {
        var date = new Date();
        var seperator1 = "-";
        var seperator2 = ":";
        //以下代码依次是获取当前时间的年月日时分秒
        var year = date.getFullYear();
        var month = date.getMonth();
        var strDate = date.getDate();
        var minute = date.getMinutes();
        var hour = date.getHours();
        var second = date.getSeconds();
        //固定时间格式
        if (month >= 1 && month <= 9) {
            month = "0" + month;
        }
        if (strDate >= 0 && strDate <= 9) {
            strDate = "0" + strDate;
        }
        if (hour >= 0 && hour <= 9) {
            hour = "0" + hour;
        }
        if (minute >= 0 && minute <= 9) {
            minute = "0" + minute;
        }
        if (second >= 0 && second <= 9) {
            second = "0" + second;
        }
        if (format) {
            var currentdate = year + seperator1 + month + seperator1 + strDate
                + " " + hour + seperator2 + minute + seperator2 + second;
        } else {
            var currentdate = year + seperator1 + month + seperator1 + strDate
                + " " + hour + seperator1 + minute + seperator1 + second;
        }

        return currentdate;
    }
    // 时间
    Vue.prototype.getNow = function (day, type) {
        let dt = new Date();
        var seperator1 = "-";
        var seperator2 = ":";
        if (day) {
            dt = new Date(dt.getTime() + 3600 * 1000 * 24 * day);
        }
        const y = dt.getFullYear();
        const m = (dt.getMonth() + 1 + "").padStart(2, "0");
        const d = (dt.getDate() + "").padStart(2, "0");
        const hh = (dt.getHours() + "").padStart(2, "0");
        const mm = (dt.getMinutes() + "").padStart(2, "0");
        const ss = (dt.getSeconds() + 1 + "").padStart(2, "0");
        if (type) {
            return y + seperator1 + m + seperator1 + d;
        } else {
            return y + seperator1 + m + seperator1 + d + ' ' + hh + seperator2 + mm + seperator2 + ss;
        }
    }
    // 当前时间转换
    Vue.prototype.getNowTime = function (type, day) {
        let dt = new Date();
        var seperator1 = "-";
        var seperator2 = ":";
        if (day) {
            dt = new Date(dt.getTime() + 3600 * 1000 * 24 * day);
        }
        const y = dt.getFullYear();
        const m = (dt.getMonth() + 1 + "").padStart(2, "0");
        const d = (dt.getDate() + "").padStart(2, "0");
        const hh = (dt.getHours() + "").padStart(2, "0");
        const mm = (dt.getMinutes() + "").padStart(2, "0");
        const ss = (dt.getSeconds() + 1 + "").padStart(2, "0");
        let timeObj = {
            'yy': y + '',
            'yy-mm':y + seperator1 + m,
            'yy-mm-dd': y + seperator1 + m + seperator1 + d,
            'yy-mm-01': y + seperator1 + m + seperator1 + '01',
            'yy-mm-31': y + seperator1 + m + seperator1 + '31',
            'yy-mm-dd 00': y + seperator1 + m + seperator1 + d + ' ' + '00' + seperator2 + '00' + seperator2 + '00',
            'yy-mm-dd 59': y + seperator1 + m + seperator1 + d + ' ' + '23' + seperator2 + '59' + seperator2 + '59',
            "yy-mm-dd hh:mm:ss": y + seperator1 + m + seperator1 + d + ' ' + hh + seperator2 + mm + seperator2 + ss,
            "yy-mm-dd hh:mm:ss +dd": y + seperator1 + m + seperator1 + (+d + 1 + '').padStart(2, "0") + ' ' + hh + seperator2 + mm + seperator2 + ss,
            "yy-mm-dd hh:mm:ss -dd": y + seperator1 + m + seperator1 + (d - 1 + '').padStart(2, "0") + ' ' + hh + seperator2 + mm + seperator2 + ss,
            "yy-mm-dd hh:mm:ss +mm": y + seperator1 + (+m + 1 + "").padStart(2, "0") + seperator1 + d + ' ' + hh + seperator2 + mm + seperator2 + ss,
            "yy-mm-dd hh:mm:ss -mm": y + seperator1 + (+m - 1 + "").padStart(2, "0") + seperator1 + d + ' ' + hh + seperator2 + mm + seperator2 + ss,
            "yy-mm-dd hh:mm:ss -mm+59": y + seperator1 + (+m - 1 + "").padStart(2, "0") + seperator1 + d + ' ' + '23' + seperator2 + '59' + seperator2 + '59',
            "yy-mm-dd hh:mm:ss -mm+00": y + seperator1 + (+m - 1 + "").padStart(2, "0") + seperator1 + d + ' ' + '00' + seperator2 + '00' + seperator2 + '00',
            "yy-mm-dd hh:mm:ss 01-00": y + seperator1 + m + seperator1 + '01' + ' ' + '00' + seperator2 + '00' + seperator2 + '00',
            "yy-mm-dd hh:mm:ss +6yy": (+y + 6 + "") + seperator1 + m + seperator1 + d + ' ' + hh + seperator2 + mm + seperator2 + ss,
            'mm-dd': m + seperator1 + d,
            "hh:mm:ss": hh + seperator2 + mm + seperator2 + ss,
            'yymmddhhmmss': y + m + d + hh + mm + ss,
            'default': y + seperator1 + m + seperator1 + d + ' ' + hh + seperator2 + mm + seperator2 + ss
        }
        if (timeObj[type]) {
            return timeObj[type];
        } else {
            return timeObj['default']
        }
    }
}